Skip to main content

break

Type

control structure

Summary

Skips the rest of the current switch structure and goes to the statement following the end switch.

Syntax

break

Description

Use the break control structure to end each case section in a switch structure.

Form: The word break appears on a line by itself, within a case section of a switch control structure.

A switch control structure consists of one or more conditions. For each condition, a set of statements is executed. The break control structure ends this set of statements and breaks out of the switch structure.

If no break appears, LiveCode executes each set of statements in the following case sections, whether or not the condition in the case is true. This means that if you leave out the break control structure, more than one case in the switch statement may be executed. Occasionally, this is desirable, but usually you should include the break control structure at the end of each case, to ensure that only one set of statements is executed.

note

The break control structure is implemented internally as a command and appears in the commandNames.

The break command should not be used outside a switch structure: such use is nonstandard, so it may not be apparent to whoever reads the code that the use is intentional. If it appears outside a switch structure, it has the same effect as the exit control structure.

Examples

switch thisVariable
case true
doSomething
break
case false
doSomethingElse
break
end switch

control structure: exit, switch

function: commandNames

glossary: statement, command, control structure, execute

keyword: case, end if, end switch

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile